package com.ereport.controller.adminController;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.ereport.dao.DailyActivityDAO;
import com.ereport.dao.ExecutiveDAO;
import com.ereport.dao.OpportunityDAO;
import com.ereport.entity.DailyActivity;
import com.ereport.entity.Executives;
import com.ereport.entity.Opportunity;

@Controller
@RequestMapping("/preEnqInAdmin")
public class PreEnqControllerInAdmin {
	@RequestMapping("/open.do")
	public ModelAndView open(HttpServletRequest req,HttpSession session,ModelAndView model){
		Executives ex=(Executives)session.getAttribute("loginUser");
		if(ex==null){
			model.setViewName("/jsp/login.jsp");
			return model;
		}
		ExecutiveDAO exdao=new ExecutiveDAO();
		List<Executives> exlist=null;
		try {
			exlist=exdao.getExecutives();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		model.setViewName("/jsp/admin/preEnqReportInAdmin.jsp");
		model.addObject("exlist", exlist);
		return model;
	}
	@RequestMapping("/rfqOpenInAdmin.do")
	public ModelAndView rfqOpen(HttpServletRequest req,HttpSession session,ModelAndView model){
		Executives ex=(Executives)session.getAttribute("loginUser");
		if(ex==null){
			model.setViewName("/jsp/login.jsp");
			return model;
		}
		String eid=req.getParameter("exeName");
		int exeid=0;
		if(eid.length()!=0){
			exeid=Integer.parseInt(eid);
		}
		OpportunityDAO opdao=new OpportunityDAO();
		List<Opportunity> oplist=new ArrayList<Opportunity>();
		try {
			oplist=opdao.getAll(exeid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		model.setViewName("/jsp/rfqReport.jsp");
		model.addObject("oplist", oplist);
		return model;
	}
	@RequestMapping("/rfqReport.do")
	public ModelAndView rfqReport(HttpServletRequest req,HttpSession session,ModelAndView model){
		//String ename=req.getParameter("exeName");
		List<Opportunity> oplist=null;
		
			OpportunityDAO opdao=new OpportunityDAO();
			oplist=new ArrayList<Opportunity>();
			try {
				oplist=opdao.getAllEnq();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
		
		model=new ModelAndView("/jsp/admin/rfqReportInAdmin.jsp");
		model.addObject("oplist", oplist);
		return model;
	}
}
